package com.miya.archetype.common.dal.dao;

import com.miya.archetype.common.dal.mapper.TradeDOMapper;
import com.miya.archetype.common.dal.entity.TradeDO;
import com.miya.archetype.common.dal.entity.TradeDOExample;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

//@Repository
public class TradeDODAOImpl implements TradeDODAO {

    private Logger logger = LoggerFactory.getLogger(TradeDODAOImpl.class);

    @Resource
    private TradeDOMapper tradeDOMapper;

    @Override
    public TradeDO getById(long id) {
        return tradeDOMapper.selectByPrimaryKey(id);
    }

    private TradeDOExample conditionAppend (TradeDO tradeDO) {
        logger.warn("test common-dal-digest...");
        TradeDOExample tradeDOExample = new TradeDOExample();
        TradeDOExample.Criteria criteria = tradeDOExample.createCriteria();
        if (tradeDO.getCreated() != null) {
            criteria.andCreatedEqualTo(tradeDO.getCreated());
        }
        logger.error("test common-dal-digest...");
        return tradeDOExample;
    }

    @Override
    public long count(TradeDO tradeDO) {
        return tradeDOMapper.countByExample(conditionAppend(tradeDO));
    }
}
